package com.hncboy.chatgpt.front.controller;

import cn.hutool.core.bean.BeanUtil;
import com.hncboy.chatgpt.base.domain.entity.ChatCustomerDO;
import com.hncboy.chatgpt.base.domain.mongodb.VerificationCode;
import com.hncboy.chatgpt.base.handler.response.R;
import com.hncboy.chatgpt.front.domain.request.VerifySecretRequest;
import com.hncboy.chatgpt.front.domain.vo.ApiModelVO;
import com.hncboy.chatgpt.front.domain.vo.ChatCustomerVO;
import com.hncboy.chatgpt.front.service.AuthService;
import com.hncboy.chatgpt.front.service.CustomerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author hncboy
 * @date 2023/3/22 19:48
 * 鉴权相关接口
 */
@AllArgsConstructor
@Tag(name = "鉴权相关接口")
@RestController
@RequestMapping
public class AuthController {

    private final AuthService authService;
    private final com.hncboy.chatgpt.front.service.CustomerService customerService;

    @Operation(summary = "模型信息")
    @GetMapping("/session")
    public R<ApiModelVO> getApiModel() {
        return R.data(authService.getApiModel());
    }

    @Operation(summary = "模型信息")
    @GetMapping("/info/{customerId}")
    public R<ChatCustomerVO> infoCustomer(@PathVariable Long customerId) {
        return R.data(authService.infoCustomer(customerId));
    }

    @Operation(summary = "验证密码")
    @PostMapping("/verify")
    public R<ChatCustomerVO> verifySecretKey(@RequestBody @Validated VerifySecretRequest verifySecretRequest) throws Exception {
        return R.data(authService.verifySecretKey(verifySecretRequest));
    }

    @Operation(summary = "发送验证码")
    @PostMapping("/send")
    public R<VerificationCode> send(@RequestBody @Validated VerifySecretRequest verifySecretRequest) {
        return R.data(authService.send(verifySecretRequest));
    }

    @Operation(summary = "修改用户信息")
    @PostMapping("/update")
    public R<Boolean> savePhone(@RequestBody ChatCustomerDO chatCustomerDO) {
        return R.data(authService.updateCustomer(chatCustomerDO));
    }

//    @GetMapping("/initInvite")
//    public void initInvite() {
//        customerService.initInvite();
//    }

}
